<template>
	<G__TopNav/>

</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { mapGetters, mapState, useStore } from "vuex";
import G__TopNav from "@/components/TopNav.vue";

export default defineComponent({
	name: "page__ajax",
	components: {G__TopNav},
	data() {
		return {
			num: 1234567
		}
	},

	mounted() {
		// see http://www.axios-js.com/docs/vue-axios.html
		// see http://www.axios-js.com/zh-cn/docs/
		// 添加请求拦截器
		this.axios.interceptors.request.use(function (config) {
			console.log('在发送请求之前做些什么')
			return config;
		}, function (error) {
			// 对请求错误做些什么
			return Promise.reject(error);
		});

		// 添加响应拦截器
		this.axios.interceptors.response.use(function (response) {
			console.log('对响应数据做点什么')
			return response;
		}, function (error) {
			// 对响应错误做点什么
			return Promise.reject(error);
		});

		this.$http.get('http://127.0.0.1:8360/test/index/index').then((response) => {
			console.group('-----------------------');
			console.log(response.data)
			console.groupEnd();
		})
	},

	setup() {
		// 组合是API中使用store
		const store = useStore()

		const storeX = computed(() => store.state.moduleA.x)

		return {
			storeX
		}
	}
})
</script>

<style scoped lang="less">

</style>
